﻿@model List<检查页面开放.Models.MethodInfo>

@{
    ViewBag.Title = "title";
    Layout = null;
    var methodList = Model as List<检查页面开放.Models.MethodInfo>;
}

<script src="~/Scripts/jquery-1.10.2.js"></script>
<div>
    <button onclick="refreshMd(this)">刷新文档</button>
</div>
@{
    var groupList = methodList.GroupBy(t => t.ClassName);
    var classCount = 1;
    <span>总计：@methodList.Count</span>
    foreach (var group in groupList)
    {
        <div style="border: solid 1px #000000; margin-top: 10px;">
            <div style="font-weight: bold; cursor: pointer;" onclick="showBkfDiv(this)">@(classCount++)类名称：@group.Key<span>展开/折叠</span></div>
            <div style=" display: none;">
                @{
                    var a = 1;
                    foreach (var collection in group)
                    {
                        <div style="border: 1px solid #000000"><span>@(a++)、</span>@collection.MethodName <a href="javascript:void(0);" onclick="viewRemark(this)" mkUrl='@Path.Combine("Md",@group.Key,@group.Key+"_"+@collection.MethodName+".md")'>说明</a></div>
                    }
                }
            </div>
        </div>
    }
}
<script>

    function showBkfDiv(obj) {
        $(obj).next().toggle();
    }
    function viewRemark(obj) {
        var name = $(obj).attr("mkUrl");
        var url = "@Url.Action("ViewRemark", "GetAppApi")?name=" +name;
        window.open(url);
    }

    function refreshMd(obj) {
        var $obj = $(obj);
        $obj.attr("disabled", "disabled");
        $.ajax({
            url: "@Url.Action("RefreshMd", "GetAppApi")",
            success: function () {
                alert("更新成功！");
            },
            error: function() {
                alert("更新失败！");
            },
            complete: function () {
                $obj.removeAttr("disabled");
            }
        });
    }

</script>